package com.ithm.controller;


import com.ithm.pojo.Visa;
import com.ithm.service.VisaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class VisaController {

    @Autowired
    private VisaService visaService;

    @GetMapping("/visa")
    public List<Visa> findAll(){
        List<Visa> all = visaService.findAll();
        return all;
    }

    @GetMapping("/findById/{id}")
    public Visa findById(@PathVariable("id") Integer id){
        return visaService.findById(id);
    }

    @PostMapping("/add")
    public int save(Visa visa){
        return visaService.save(visa);
    }

    @PutMapping("/update/{id}")
    public int update(Visa visa){
        return visaService.update(visa);
    }

    @DeleteMapping("/delete/{id}")
    public int delete(@PathVariable("id") Integer id){
        return visaService.delete(id);
    }
}
